/*

This file is part of Ext JS 4

Copyright (c) 2011 Sencha Inc

Contact:  http://www.sencha.com/contact

GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.

If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.

*/
Ext.require('Ext.chart.*');
Ext.require(['Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit']);

Ext.onReady(function () {
    
                                        Ext.data.JsonP.request({
                                            url: 'http://153.121.40.23:8080/aios-api/aios/api/GetAmountPower?tap_group_id=3&report_type=2&date_start=2014-07-12&date_end=2014-07-12',
                                            type: 'GET',
                                            crossDomain: true,
                                            dataType: "json",
                                            callbackkey: 'callback',
                                            scope: this,
                                            /* params: {
                                                tap_id: 1
                                            }, */
                                            scope: this,      /// fix handler scope
    
                                            callback: function (response, value, request) {
                                                storeCurrentYearStatisticsData(value);
                                                
                                              //  Ext.Msg.alert("Current Sucessfully");
                                                
                                                Ext.data.JsonP.request({
                                                    url: 'http://153.121.40.23:8080/aios-api/aios/api/GetAmountPower?tap_group_id=3&report_type=2&date_start=2013-07-12&date_end=2013-07-12',
                                                    type: 'GET',
                                                    crossDomain: true,
                                                    dataType: "json",
                                                    callbackkey: 'callback',
                                                    scope: this,
                                             
                                                    scope: this,      /// fix handler scope
            
                                                    callback: function (response, value, request) {
                                                    //	Ext.Msg.alert("Past Sucessfully");
                                                        storePastYearStatisticsData(value);
                                                    },
                                                    

                                                    failure: function (response, request) {
                                                        Ext.Msg.alert("申し訳ありませんが、再試行してください... </br>"+response);
                                                    }
                                                });
                                            },
                                            

                                            failure: function (response, request) {
                                                Ext.Msg.alert("申し訳ありませんが、再試行してください... </br>"+response);
                                            }
                                        }); 
                                        
                                        

    var win = Ext.create('Ext.Window', {
        width: '100%',
        height: '100%',
    
        hidden: false,
        //maximizable: true,
        resizable: true,
        title: '',
        renderTo: Ext.getBody(),
        layout: 'fit',
        maximized: true,

     

        
        items: {
            id: 'chartCmp',
            xtype: 'chart',
            style: 'background:#fff',
            animate: true,
            theme: 'Category1',
            store: storeStatistic,
            legend: {
                        position: 'top'
                    },
            axes: [{
                type: 'Numeric',
                position: 'left',
                fields: ['Current_Year_Total','Current_Year_Max','Past_Year_Total','Past_Year_Max'],
                title: '電力量(kWh)',
                grid: true
            }, {
                type: 'Category',
                position: 'bottom',
                fields: ['name'],
                title: '月'
            }],
            series: [
            {
                type: 'column',
                axis: 'left',
                xField: 'name',
                yField: ['Current_Year_Total', 'Past_Year_Total'],
                title : ['2014 総電力', '2013 総電力'],
                markerConfig: {
                    type: 'cross',
                    size: 3,
                }
            },
              {
                type: 'line',
                axis: 'left',
                smooth: true,          
                fillOpacity: 0.5,
                xField: 'name',
                yField:  'Past_Year_Max',
                title : '2013 最大出力',

            },
            {
                type: 'line',
                axis: 'left',
                smooth: true,          
                fillOpacity: 0.5,
                xField: 'name',
                yField: 'Current_Year_Max',
                title : '2014 最大出力',
            }
            ]
        }
       
    });
});

